using System;
using System.Collections.Generic;
using System.Text;

namespace A4G.Core
{
	public delegate bool StateMachineDelegate<TState, TEvent>(TEvent e, ref TState outState);

	public class StateMachineEntity<TState, TEvent>
	{
		public StateMachineEntity()
		{
		}

		public StateMachineEntity(StateMachineDelegate<TState, TEvent> method)
		{
			_method = method;
		}

		private StateMachineDelegate<TState, TEvent> _method;
		protected StateMachineDelegate<TState, TEvent> Method
		{
			get { return _method; }
			set { _method = value; }
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="outState"></param>
		/// <returns>true if terminated; false otherwise</returns>
		public virtual bool ExecuteMethod(TEvent e, ref TState outState)
		{
			if (Method != null)
			{
				return Method(e, ref outState);
			}

			return true;
		}
	}
}
